{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Property of Laurent Series\n",
    "Discontinuities in the specification of $\\epsilon_r$ affect convergence. (So rectangular gratings, it shouldn't be a problem if we consider a sinusoidal grating).\n",
    "\n",
    "Laurents' rule\n",
    "\\begin{equation}\n",
    "  h_n = \\sum_{m=-\\infty}^{\\infty}  f_{n-m}g_m\n",
    "\\end{equation}\n",
    "which actually looks like the cauchy sum rule for the product of two series\n",
    "\n",
    "The Laurent's series for a function with two concurrent jump discontinuities is:\n",
    "\\begin{equation}\n",
    "    h^{(M)}(x) = h_M(x) - \\sum_{x\\in U_{fg}}\\frac{\\hat f_p\\hat g_p}{2\\pi^2}\\Phi_M(x-x_p)\n",
    "\\end{equation}\n",
    "\n",
    "One of the interesting parts of the Laurent series for two concurrently discontinuous functions.\n",
    "\\begin{equation}\n",
    "    \\Phi_M(x) = \\sum_{n=1}^{M}\\frac{cos(nx)}{n}\\sum_{|m|>M}\\frac{1}{m-n}\n",
    "\\end{equation}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAY+UlEQVR4nO3deZBd5Xnn8e9zt97VUkutfWlkwGxhCWIx2BkgKQyOl0mNM7bHlmMnLmpizxRUmBlnSE1IMpU/XKkhnpkkQyhDiGPiBSMcSGUWxmA7jANGwgJtbEYId7dEdyOp+/Zy92f+uKevuqVudUt9u6/OOb9PVdc9y9v3Psdu/Xjrvee8r7k7IiISfolGFyAiIvWhQBcRiQgFuohIRCjQRUQiQoEuIhIRqUZ98KpVq7ynp6dRHy8iEkq7du0acvfumc41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lXgPwCVYH8l8bhuB/6Pme0yszuCYwv6Ow/bItE2wzHddxlBZtYOPAbc5e4j1U5btLl7GbjSzJYDjwMXz9RsaataXGb2YWDA3XeZ2U2Th2doGqnrDtzo7v1mthp4ysxeWegbhq2H3gtsmrK/EehvUC2N8I6ZrQMIXgcaXM+iMLM01TB/xN13BIdjce0A7n4c+AHV7xCWm9lkxyuKf+83Ah81s7eoDqHeQrXHHvXrxt37g9cBqv8Bv5YF/p2HLdBfAC4IvgHPAJ8EnmhwTUvpCeA3gu3fAP6ugbUsimD89EHggLvfN+VUpK/dzLqDnjlm1gL8CtXvD54BPh40i9x1u/t/dPeN7t5D9d/z0+7+aSJ+3WbWZmYdk9vArcBeFvh3HronRc3sQ1T/C54EHnL3P25wSYvCzL4J3ER1Os13gHuB7wHfATYDbwO/7u4nf3Eaamb2fuAfgT2cGFO9h+o4emSv3cwup/olWJJqR+s77v5HZraVas+1C/gp8Bl3zzeu0sUTDLn8O3f/cNSvO7i+x4PdFPC37v7HZraSBfydhy7QRURkZmEbchERkVko0EVEIkKBLiISEQp0EZGIUKCLiESEAl1EJCIU6CIiEfH/AeFklXunHT0QAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "def Phi(M,x):\n",
    "    f = 0;\n",
    "    for i in range(1, M+1):\n",
    "        subsum = 0;\n",
    "        for m in range(M+1,100*M):\n",
    "            subsum+=(1/(m-i))+(1/(-m-i));\n",
    "        f+= (np.cos(i*x)/i)*subsum;\n",
    "        \n",
    "    return f;\n",
    "\n",
    "sequences = []\n",
    "for M in np.linspace(1,100):\n",
    "    sequences.append(Phi(int(M),0));\n",
    "\n",
    "plt.plot(sequences)\n",
    "plt.axhline((np.pi**2)/4)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## observation\n",
    "One can imagine that one could accelerate the convergence of this series using the Shanks transform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
